package server

import (
	"fmt"
	"log"
	"net/http"
)

func Run() {
	http.HandleFunc("/hello", hello)
	log.Println("Starting v1 server ...")
	log.Fatal(http.ListenAndServe(":8081", nil))
}

func hello(w http.ResponseWriter, r *http.Request) {

	var clientAddr = ""
	clientAddr = r.RemoteAddr
	if clientAddr == "" {
		r.Header.Get("Remote_addr")
	}
	fmt.Println(clientAddr)
	_, err := w.Write([]byte("bye bye [hello],addr:" + clientAddr))
	if err != nil {
		fmt.Println(err)
	}
}
